var upload = {
    uploadImage:function(position){
        var options = {
            beforeSerialize : function(form, options) {
                options.url = '../upload/uploadFile';
            },
            beforeSubmit : function() {
                $('#'+position+'ImageForm').attr('action', '../upload/uploadFile');
                return true;
            },
            success : function(data) {
                data = data.replace("<pre>","").replace("</pre>","").replace("<PRE>","").replace("</PRE>","");
                data = $.parseJSON(data)
                if(data.result == 'success'){
                    $('#imagePath').val(data.filePath);
                    $('#productImagePreview').attr("src",config.baseURL+data.filePath);
                }else{
                   $.msgBox.alert({
                        title : 'Tips',
                        msg : 'Upload image error,please try again later!',
                        icon : 'warning',
                        width : 400
                    });
                }
            }
        };

        $('#'+position+'ImageForm').submit(function() {
            $(this).ajaxSubmit(options);
            return false;
        });
    }
};